<!--
 Copyright 2025 Google LLC

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<h1 mat-dialog-title class="text-2xl font-semibold">
  {{ data.asset.id ? 'Edit' : 'Create' }} Source Asset
</h1>
<div mat-dialog-content>
  <form
    [formGroup]="form"
    class="grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-1 pt-3"
  >
    <mat-form-field appearance="outline" class="md:col-span-2">
      <mat-label>Filename</mat-label>
      <input matInput formControlName="originalFilename" required />
      <mat-error *ngIf="form.get('originalFilename')?.hasError('required')"
        >Filename is required</mat-error
      >
    </mat-form-field>

    <mat-form-field appearance="outline">
      <mat-label>Scope</mat-label>
      <mat-select formControlName="scope" required>
        <mat-option *ngFor="let scope of assetScopes" [value]="scope">{{
          scope | titlecase
        }}</mat-option>
      </mat-select>
      <mat-error *ngIf="form.get('scope')?.hasError('required')"
        >Scope is required</mat-error
      >
    </mat-form-field>

    <mat-form-field appearance="outline">
      <mat-label>Asset Type</mat-label>
      <mat-select formControlName="assetType" required>
        <mat-option *ngFor="let type of assetTypes" [value]="type">{{
          type | titlecase
        }}</mat-option>
      </mat-select>
      <mat-error *ngIf="form.get('assetType')?.hasError('required')"
        >Asset Type is required</mat-error
      >
    </mat-form-field>

    <mat-form-field appearance="outline" class="md:col-span-2">
      <mat-label>GCS URI</mat-label>
      <input
        matInput
        formControlName="gcsUri"
        required
        placeholder="gs://bucket-name/path/to/asset.png"
      />
      <mat-error *ngIf="form.get('gcsUri')?.hasError('required')"
        >GCS URI is required</mat-error
      >
    </mat-form-field>
  </form>
</div>
<div mat-dialog-actions align="end">
  <button mat-button (click)="onCancel()">Cancel</button>
  <button
    mat-raised-button
    color="primary"
    (click)="onSave()"
    [disabled]="!form.valid"
  >
    Save
  </button>
</div>
